-- Viral Resistance - T-Engine 4 Module
-- Copyright (C) 2010 Mikolai Fajer
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.
--
-- Mikolai Fajer "yufra"
-- mfajer@gmail.com

load("/data/general/grids/basic.lua")


newEntity{
	define_as = "GENERATOR",
	name = "generator",
	display = '~', color=colors.SLATE,
	color_br=41, color_bg=77, color_bb=106,
	block_sight = true,
	does_block_move = true,
	dig = "FLOOR",
	tooltip = "A large generator.",
}

newEntity{ base = "FLOOR",
	define_as = "CONDUIT_BASE",
	color=colors.DARK_BLUE,
	name = "power conduit",
	dig = "FLOOR",
	tooltip = "A large bundle of power cables hang from the ceiling.",
}

newEntity{ base="CONDUIT_BASE",
	define_as = "CONDUIT_VERTICAL",
	display = '|',
	add_displays = {
		engine.Entity.new{
			display_on_seen = true,
			display_on_remember = true,
			display = '|', color=colors.DARK_BLUE
		},
	},
}

newEntity{ base="CONDUIT_BASE",
	define_as = "CONDUIT_HORIZONTAL",
	display = '-',
	add_displays = {
		engine.Entity.new{
			display_on_seen = true,
			display_on_remember = true,
			display = '-', color=colors.DARK_BLUE
		},
	},
}

newEntity{ base="CONDUIT_BASE",
	define_as = "CONDUIT_FORWARDSLASH",
	display = '/',
	add_displays = {
		engine.Entity.new{
			display_on_seen = true,
			display_on_remember = true,
			display = '/', color=colors.DARK_BLUE
		},
	},
}

newEntity{ base="CONDUIT_BASE",
	define_as = "CONDUIT_BACKSLASH",
	display = '\\',
	add_displays = {
		engine.Entity.new{
			display_on_seen = true,
			display_on_remember = true,
			display = '\\', color=colors.DARK_BLUE
		},
	},
}

newEntity{ base="CONDUIT_BASE",
	define_as = "CONDUIT_BROKEN",
	display = '^',
	add_displays = {
		engine.Entity.new{
			display_on_seen = true,
			display_on_remember = true,
			display = '^', color=colors.DARK_BLUE
		},
	},
	damage = resolvers.rngrange(10,15),
	name = "broken power conduit",
	tooltip = "A large bundle of power cables hang from the ceiling.",
	can_talk = "broken_conduit",
	-- Initiate zombie spawning when the mechanic enters the tile
	on_move = function(self, x, y, who, forced)
		if who.name == "Mechanic" then
			-- Add counts to the spawn sites
			for i=1,rng.range(2,4) do
				local spot = game.level:pickSpot({type="director", subtype="spawn"})
				spot.count = (spot.count or 0) + 1
				print("[[DEBUG]] adding a spawn counter to ", spot.x, " :: ", spot.y)
			end
			game.logSeen(who, "%s begins working on the broken conduit and making quite a racket.", who.name:capitalize())
		end
	end
}